package com.rabbit.mq.web;

import com.rabbit.mq.util.MsgDataUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @version V1.0.0
 * @ClassName: {@link TopicSendController}
 * @Description: SendMessageController
 * @author: Lanzhou
 * @date: 2021/3/17 9:58
 * @Copyright:2020 All rights reserved.
 */
@RestController
@RequestMapping("/topic")
public class TopicSendController {

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送
     */
    @RequestMapping("/sent")
    public String sent() {
        Map<String, String> map = MsgDataUtil.buildMsg();
        String messageData = "test message, hello!";
        map.put("messageData", messageData);
        rabbitTemplate.convertAndSend("exchange", "queue_exchange_01", map);
        return "{\"code\":200,\"msg\":\"SUCCESS\"}";
    }



}
